<?php
/**
 * @package qBase
 * @subpackage web
 */

/**
 * QWebDelegate represents the base for any delegate that links to a browser event
 * 
 * @package qBase
 * @subpackage web
 */
class QWebDelegate extends QDelegate 
{
	/**
	 * The items to be sent in the postback request, the variabile is a string 
	 * that is like a CSS rule (just like jQuery is using it)
	 *
	 * @var string
	 */
	// private $postback; // NOT USED YET!
	/**
	 * The constructor of QWebDelegate
	 *
	 * @param QObject $callback_object The object that contains the call back method
	 * @param string $callback_method The call back method
	 * @param mixed $parameters The delegate's parameters
	 */
	public function __construct(QObject $callback_object, $callback_method, $parameters = null)
	{
		parent::__construct($callback_object, $callback_method, $parameters);
	}
	
	/**
	 * The type of the delegate that is for now the classname
	 *
	 * @return string
	 */
	public function getType()
	{
		return $this->getClassName();
	}
	
	/**
	 * Pust the delegate in the JS stream making the javascript objects aware of the delagate, based on the deleagayes type the 
	 * browser will know what to do. For example for a QWebAjaxDelegate an ajax request will be made
	 *
	 * @return string The js encoded data to be sent
	 */
	public function toJsStream()
	{
		return json_encode(array("type" => get_class($this)));
	}
}

?>